<!--
Module: NBIOT 配置页面
Author: 吴金根
date:2017/11/20
-->
<template>
    <div class="nav-box">
      
      <!-- <div class="nav-list">
          <ul>
               <li v-for="(item, index) in list" :class="{'current':index==currennt}" :key="item"><router-link :to="item.url">{{item.name}}</router-link></li>
          </ul>
      </div> -->
      <div class="nav-list">
          <ul>
               <li class="haveson" :class="{'current':indexs==0}">
                   <span class="nav-txt">
                        <a href="javascript:vold(0)" >站点数据</a>
                        </span>
                        
                   <dl class="children-list">
                       <dd>
                            <router-link to="/RealData">实时数据</router-link>
                        </dd>
                      
                   </dl>
               </li>
               <li class="haveson" :class="{'current':indexs==1}">
                    <span class="nav-txt">
                        <a href="javascript:vold(0)" >配置管理</a>
                        </span>
                       
                   <dl class="children-list">
                     
                       <dd>
                            <router-link to="/pageconfig">基础配置</router-link>
                        </dd>
                        <dd>
                           <router-link to="/addconfig">驱动配置</router-link>
                        </dd>
                         <dd>
                          <router-link to="/Nbiot">NBIOT配置</router-link>
                        </dd>
                   </dl>
              </li>
               <li :class="{'current':indexs==2}">
                    <span class="nav-txt">
                        日志管理
                    </span>
              </li>
             
               
          </ul>
      </div>
    </div>
</template>


<script>
export default {
  props: ["indexs"],
  data() {
    return {
      token: "6f5ffdab-9dd9-4864-ab4a-658418e3ee56",
      currennt: 0,
      list: [
        {
          name: "unitalk配置页面",
          url: "/addconfig"
        },
        {
          name: "unitalk实时数据界面",
          url: "/RealData"
        },
        {
          name: "NBIOT平台",
          url: "/Nbiot"
        }
      ]
    };
  },

  methods: {
    gettoken() {
      let self = this;
      jQuery.ajax({
        type: "POST",
        url: "/unitalk/v1.0/auth.json",
        contentType: "application/json",
        data: JSON.stringify({
          name: "heda",
          pwd: 123456
        }),
        dataType: "json",
        success: function(rep) {
          if (typeof rep == "string") {
            try {
              rep = JSON.parse(rep);
            } catch (err) {
              rep = {
                Code: 99999,
                Message: "登录失败，请稍后再试！"
              };
            }
          }
          if (rep.Code == 0) {
            self.token = rep.Response.Token;
             
             this.$emit("clickit", self.token);
          } else {
            self.$message.error(rep.Message);
          }
        }
      });
    
    }
  },

  mounted() {
    let self = this;
    /*------执行登录获取参数------*/
    self.gettoken();
  }
};
</script>
